package com.platform.common.util.query.vo;

/**
 * 分页参数
 * 
 * @date Sep 19, 2017:8:02:08 PM
 * @desc com.netbox.json
 */
public class Page {

	// 当前页数
	private int pageIndex = 1;
	// 每页记录数
	private int pageCount = 30;

	// 分页数据开始页位置
	private int startIndex = 1;
	// 分页数据结束页位置
	private int endIndex = 30;

	public Page(int pageIndex, int pageCount) {
		this.pageIndex = pageIndex;
		this.pageCount = pageCount;

		int page = (pageIndex > 0) ? pageIndex : 1;
		startIndex = (page - 1) * pageCount;
		endIndex = page * pageCount;
	}

	public Page() {
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
		int page = (pageIndex > 0) ? pageIndex : 1;
		startIndex = (page - 1) * pageCount;
	}

	public int getPageIndex() {
		return this.pageIndex;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
		int page = (pageIndex > 0) ? pageIndex : 1;
		endIndex = page * pageCount;
	}

	public int getPageCount() {
		return this.pageCount;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public int getEndIndex() {
		return endIndex;
	}

	@Override
	public String toString() {
		return "Page [pageIndex=" + pageIndex + ", pageCount=" + pageCount + ", startIndex=" + startIndex + ", endIndex=" + endIndex + "]";
	}

	public static void main(String[] args) {
		// Page page = new Page(2, 30);
		// System.out.println(page);
		Page page = new Page();
		page.setPageIndex(2);
		page.setPageCount(30);
		System.out.println(page);
	}
}
